from django.contrib.auth.models import Permission, ContentType

from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet

from apps.meiduo_admin.utils import PageNum
from apps.meiduo_admin.serializers.permission import PermissionSerializer, ContentTypeSerializer


class PermissionViewSet(ModelViewSet):
    # 获取查询集
    queryset = Permission.objects.all().order_by('id')
    # 指定序列化器
    serializer_class = PermissionSerializer
    # 指定分页器
    pagination_class = PageNum


class ContentTypeView(ListAPIView):
    # 获取权限类型数据
    queryset = ContentType.objects.all()
    # 指定序列化器
    serializer_class = ContentTypeSerializer
